﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Kokomo.PeInspector.Extensibility;
using System.ComponentModel.Composition;
using Kokomo.PeInspector.Reflection;
using Kokomo.Environment.Commanding;

namespace Kokomo.PeInspector.SampleExtension
{
	[Export(typeof(IDetailViewModelExtender))]
	public class SampleExtender : IDetailViewModelExtender
	{
		public void Extend(DetailViewModel viewmodel, IMetadataHost host)
		{
			viewmodel.Summary.Details.Add(new SummaryDetailViewModel("Extended detail", "value"));
			viewmodel.Summary.Details.Add(new SummaryDetailLinkViewModel(
				"Extended detail link",
				"link text",
				new DelegatedCommand(this.CommandImpl)
				));

			viewmodel.Summary.Commands.Add(new CommandViewModel(
				new DelegatedCommand(this.CommandImpl),
				"Extension command"
				) { Argument = viewmodel.Object });

			TabbedDetailViewModel tabbed = viewmodel as TabbedDetailViewModel;
			if (tabbed != null)
			{
				tabbed.Tabs.Add(new TabPageViewModel(
					"Extended tab",
					new ExtensionViewModel()
					));
			}
		}

		private void CommandImpl(object arg)
		{
		}
	}
}
